<?php
require_once 'D:\fbg_gd\php_demo\vendor\autoload.php';
use phpspider\core\phpspider;

/* Do NOT delete this comment */
/* 不要删除这段注释 */

$configs = array(
    'name' => '糗事百科',
    'log_show'=>false,
    'domains' => array(
        'word.qsbdc.com',
    ),
    'scan_urls' => array(
        'http://word.qsbdc.com'
    ),
    'content_url_regexes' => array(
        "http://word.qsbdc.com/wl.php?level=1&&tag=all&&page_id=\d+"
    ),
    'list_url_regexes' => array(
        "http://word.qsbdc.com/wl.php?level=1&&tag=all&&page_id=\d+"
    ),
    'fields' => array(
        array(
            // 抽取内容页的文章内容
            'name' => "table",
            'selector' => "//span[contains(@class,'hidden_1_1')]",
            'required' => true
        )
    ),
);

//$spider = new phpspider($configs);
//
//$spider->on_start = function($phpspider)
//{
//
//};
//
//$spider->on_scan_page = function($page, $content, $phpspider)
//{
//    for ($i = 1; $i <= 10; $i++)
//    {
//        $url = "http://word.qsbdc.com/wl.php?level=1&&tag=all&&page_id={$i}";
//
//        $html = \phpspider\core\requests::get($url);
//        // 选择器规则
//        $selector = "//span[contains(@class,'hidden_1_1')]";
//        // 提取结果
//        $result = \phpspider\core\selector::select($html, $selector);
//        \phpspider\core\log::$log_file = "D:\\fbg_gd\\php_demo\\net\\phpspider\\data\\phpspider.log";
//        \phpspider\core\log::info(print_r($result));
//    }
//};

//$spider->start();

/*
$url = "http://word.qsbdc.com/wl.php?level=1&&tag=all&&page_id=2";
$html = \phpspider\core\requests::get($url);
// 选择器规则
$selector = "//span[contains(@class,'hidden_1_1')]";
// 提取结果
$result = \phpspider\core\selector::select($html, $selector);

print_r($result);
die();
*/

$url = "https://www.youdao.com/w/fifty/#keyfrom=dict2.top";
$html = \phpspider\core\requests::get($url);
// 选择器规则
$selector = "//div[contains(@id,'phrsListTab')]//div[contains(@class,'trans-container')]//ul//li";
// 提取结果
$result = \phpspider\core\selector::select($html, $selector);

print_r($result);
die();
